package com.awenlchan.servicedemo;

import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

public class MusicActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_music);

    }
    public void play(View view )throws Exception{
        command("play");
    }
    public void stop(View view){
        command("stop");
    }
    public void pause(View view){
        command("pause");
    }
    private void command(String command){
        Intent intent = new Intent();
//        intent.setClass(this,MusicService.class);
        intent.setAction("music");
        intent.setPackage(this.getPackageName());
        intent.putExtra("action",command);
        startService(intent);
    }
}
